/*
 * main.c
 *
 *  Created on: Jan 30, 2013
 *      Author: justin
 */
#include "project.h"
//#include "FSM.h"


static  portTASK_FUNCTION(LedFlashTask1,pvParameters){
//void LedFlashTask1(void* pvParameters)
//{
	DDRF = 0xff;
	PORTF = 0b10101010;
	int i=0;
	while(1) PORTF=i++;	//gets here, runs for 932us and crashes.

	while(1)
	{
		//sbi(PORTE,5);
		PORTF=0xff;
		//vTaskDelay(100/portTICK_RATE_MS);
		//while (1) {PORTE=0xff; PORTE=0x00;}
		//cbi(PORTE, 5);
		PORTF=0x00;
		//vTaskDelay(500/portTICK_RATE_MS);
	}
}
static  portTASK_FUNCTION(LedFlashTask2,pvParameters){
	DDRF=0xff;
	uint8_t i=0;
	PORTF = ~(i--);
}

int main() {


	DDRF = 0xff;
	 //test port output
	PORTF=0b10011001;
//	portDBG_TRACE("f");
	/*initialize serial*/
	//DDRB= 0x00;
	//xSerialPortInitMinimal(ser9600,75);
//portENTER_CRITICAL();
	/*start tasks*/
//	xTaskCreate(FSM_task,(signed portCHAR *)"FSM_task",configMINIMAL_STACK_SIZE,
//			NULL,2,NULL);
	xTaskCreate(LedFlashTask1, (signed portCHAR *)"LedFlashTask1", configMINIMAL_STACK_SIZE, NULL, 2, NULL );
	xTaskCreate(LedFlashTask2, (signed portCHAR *)"LedFlashTask2", configMINIMAL_STACK_SIZE, NULL, 2, NULL );
		PORTF=0b01100110;

//	xTaskCre
vTaskStartScheduler();
	uint8_t i=0;
	while (1) {while(1){PORTF=i++;} }/*if everything goes well, we never get here*/


}
